# Maintainer: Andrea Zagli <andrea.zagli.free@gmail.com>

_realname=libodfgen
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.1.8
pkgrel=3
pkgdesc="Library to generate ODF documents (mingw-w64)"
arch=('any')
url="https://sourceforge.net/p/libwpd/libodfgen/"
license=("LGPL 2.1")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-pkg-config"
             "${MINGW_PACKAGE_PREFIX}-doxygen")
depends=("${MINGW_PACKAGE_PREFIX}-libxml2"
         "${MINGW_PACKAGE_PREFIX}-librevenge")
options=(staticlibs strip)
source=("https://sourceforge.net/projects/libwpd/files/libodfgen/${_realname}-${pkgver}/${_realname}-${pkgver}.tar.xz")
sha256sums=('55200027fd46623b9bdddd38d275e7452d1b0ff8aeddcad6f9ae6dc25f610625')

prepare() {
  cd ${srcdir}/${_realname}-${pkgver}
  autoreconf -fiv
}

build() {
  [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}
  cp -r ${srcdir}/${_realname}-${pkgver} "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  ./configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --enable-shared \
    --enable-static \
    --with-docs=yes

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING.LGPL" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING.LGPL"
  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING.MPL" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING.MPL"
}
